/**
 * Copyright (C) 2012 The SkyTvOS Project
 * <p/>
 * Version     Date           Author
 * ─────────────────────────────────────
 * 2015年4月8日         Root.Lu
 */

package com.coocaa.x.service.litecontent.providers.system.host;

import android.content.Context;
import android.net.Uri;

import com.coocaa.x.service.XServiceManager;
import com.coocaa.x.service.litecontent.LiteContentProvider;
import com.coocaa.x.service.litecontent.LiteContentProvider.LiteContentProviderHost;
import com.coocaa.x.service.litecontent.LiteContentProvider.ResourceHandler;
import com.coocaa.x.service.litecontent.data.ResultPackage;

public class SystemHost_Com_Coocaa_CC4X extends LiteContentProviderHost {
    private static SystemHost_Com_Coocaa_CC4X instance = null;

    public static synchronized void create(Context context, LiteContentProvider provider) {
        if (instance == null)
            instance = new SystemHost_Com_Coocaa_CC4X(context, provider);
    }

    private static final String MY_HOST = "com.coocaa.cc4x";

    public SystemHost_Com_Coocaa_CC4X(Context context, LiteContentProvider provider) {
        super(context, provider);
    }

    @Override
    public String myHost() {
        return MY_HOST;
    }

    @SuppressWarnings("unused")
    // 2.2.1、信号源
    private ResourceHandler tv_source_list = new ResourceHandler(this, "/tv_source_list") {
        @Override
        public ResultPackage call(Uri uri) {
            ResultPackage rp = new ResultPackage();
            try {
                XServiceManager.getLiteCCConnectorService().startSourceSwitch();
            } catch (Exception e) {
                rp.error_msg = e.getMessage();
                rp.error_code = -1;
            }
            return rp;
        }
    };

    @SuppressWarnings("unused")
    // 2.2.2、本地媒体
    private ResourceHandler local_media = new ResourceHandler(this, "/local_media") {
        @Override
        public ResultPackage call(Uri uri) {
            ResultPackage rp = new ResultPackage();
            try {
                XServiceManager.getLiteCCConnectorService().startMediaBrowser();
            } catch (Exception e) {
                rp.error_msg = e.getMessage();
                rp.error_code = -1;
            }
            return rp;
        }
    };

    @SuppressWarnings("unused")
    // 2.2.3、网络设置
    private ResourceHandler net_setting = new ResourceHandler(this, "/net_setting") {
        @Override
        public ResultPackage call(Uri uri) {
            ResultPackage rp = new ResultPackage();
            try {
                XServiceManager.getLiteCCConnectorService().startNetSetting();
            } catch (Exception e) {
                rp.error_msg = e.getMessage();
                rp.error_code = -1;
            }
            return rp;
        }
    };

    @SuppressWarnings("unused")
    // 2.2.4、电视设置
    private ResourceHandler system_setting = new ResourceHandler(this, "/system_setting") {
        @Override
        public ResultPackage call(Uri uri) {
            ResultPackage rp = new ResultPackage();
            try {
                XServiceManager.getLiteCCConnectorService().startTVSetting();
            } catch (Exception e) {
                rp.error_msg = e.getMessage();
                rp.error_code = -1;
            }
            return rp;
        }
    };

    @SuppressWarnings("unused")
    // 2.2.5、系统升级
    private ResourceHandler system_upgrade = new ResourceHandler(this, "/system_upgrade") {
        @Override
        public ResultPackage call(Uri uri) {
            ResultPackage rp = new ResultPackage();
            try {
                XServiceManager.getLiteCCConnectorService().startSystemUpgrade();
            } catch (Exception e) {
                rp.error_msg = e.getMessage();
                rp.error_code = -1;
            }
            return rp;
        }
    };

    @SuppressWarnings("unused")
    // 2.2.6、本机信息
    private ResourceHandler device_info = new ResourceHandler(this, "/device_info") {
        @Override
        public ResultPackage call(Uri uri) {
            ResultPackage rp = new ResultPackage();
            try {
                XServiceManager.getLiteCCConnectorService().startDeviceInfo();
            } catch (Exception e) {
                rp.error_msg = e.getMessage();
                rp.error_code = -1;
            }
            return rp;
        }
    };

    @SuppressWarnings("unused")
    // 2.2.7、多屏互动
    private ResourceHandler qrcode = new ResourceHandler(this, "/qrcode") {
        @Override
        public ResultPackage call(Uri uri) {
            ResultPackage rp = new ResultPackage();
            try {
                XServiceManager.getLiteCCConnectorService().starQRCode();
            } catch (Exception e) {
                rp.error_msg = e.getMessage();
                rp.error_code = -1;
            }
            return rp;
        }
    };

}
